package com.fzdy.product.dao.impl;

import com.fzdy.product.base.dao.impl.BaseNativeSqlRepository;
import com.fzdy.product.dao.FinalProductDao;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.Query;

@Repository
public class FinalProductDaoImpl extends BaseNativeSqlRepository implements FinalProductDao {

    @Override
    public void batchSave(String beginSn, int deviceNum, String tname) {
        EntityManager em = emf.createEntityManager();
        String sql = "call p_insert_devicesn(:inParam1,:inParam2,:inParam3);";
        Query query = em.createNativeQuery(sql).setParameter("inParam1", beginSn).setParameter("inParam2",deviceNum).setParameter("inParam3",tname);
        query.getResultList();

        em.close();
    }

    @Override
    public void batchDel(String beginSn, int deviceNum, String tname) {
        EntityManager em = emf.createEntityManager();
        String sql = "call p_delete_devicesn(:inParam1,:inParam2,:inParam3);";
        Query query = em.createNativeQuery(sql).setParameter("inParam1", beginSn).setParameter("inParam2",deviceNum).setParameter("inParam3",tname);
        query.getResultList();
        em.close();
    }
}
